package com.briup.test.service.impl;

import com.briup.test.bean.User;
import com.briup.test.dao.UserMapper;
import com.briup.test.service.IUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

@Service
public class UserServiceImpl implements IUserService {

    @Resource
    private UserMapper userMapper;

    @Override
    public List<User> query(String name) {
        return userMapper.query(name);
    }

    @Override
    public void saveOrUpdate(User user) {
        if (user.getId() == null){
            userMapper.insert(user);
        } else {
            userMapper.update(user);
        }
    }
}

